package com.shushan.setting.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: GradeBookBean
 * @Desciption: 年级下所有课本
 * @author: yichaohua
 * @date: 2018-08-10
 */
public class GradeBookBean extends NetBaseBean {

    private List<BookBean> chineseBookList = new ArrayList<BookBean>();
    private List<BookBean> mathBookList = new ArrayList<BookBean>();
    private List<BookBean> englishBookList = new ArrayList<BookBean>();


    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        JSONArray chineseArray = jsonObject.optJSONArray(Constants.SUBJECT_CHINESE_ID + "");
        if(chineseArray != null){
            for (int i = 0;i < chineseArray.length();i++){
                JSONObject object = chineseArray.optJSONObject(i);
                BookBean bookBean = new BookBean();
                bookBean.initByJson(object);
                chineseBookList.add(bookBean);
            }
        }

        JSONArray mathArray = jsonObject.optJSONArray(Constants.SUBJECT_MACH_ID + "");
        if(mathArray != null){
            for (int i = 0;i < mathArray.length();i++){
                JSONObject object = mathArray.optJSONObject(i);
                BookBean bookBean = new BookBean();
                bookBean.initByJson(object);
                mathBookList.add(bookBean);
            }
        }

        JSONArray englishArray = jsonObject.optJSONArray(Constants.SUBJECT_ENGLISH_ID + "");
        if(englishArray != null){
            for (int i = 0;i < englishArray.length();i++){
                JSONObject object = englishArray.optJSONObject(i);
                BookBean bookBean = new BookBean();
                bookBean.initByJson(object);
                englishBookList.add(bookBean);
            }
        }
    }

    public List<BookBean> getChineseBookList() {
        return chineseBookList;
    }

    public void setChineseBookList(List<BookBean> chineseBookList) {
        this.chineseBookList = chineseBookList;
    }

    public List<BookBean> getMathBookList() {
        return mathBookList;
    }

    public void setMathBookList(List<BookBean> mathBookList) {
        this.mathBookList = mathBookList;
    }

    public List<BookBean> getEnglishBookList() {
        return englishBookList;
    }

    public void setEnglishBookList(List<BookBean> englishBookList) {
        this.englishBookList = englishBookList;
    }
}
